﻿package {
	import flash.display.*;
	import flash.events.*;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
	
	
	    public class Asteroid extends MovieClip {
		public var button = new ReverseBtn();
		public var i= 2;
		public var rev1:rev;
		
		
		public function Asteroid() 
		{

			var asteroid1:MovieClip = new AsteriodMC();
			var asteroid2:MovieClip = new AsteriodMC();
			var asteroid3:MovieClip = new AsteriodMC();
			var asteroid4:MovieClip = new AsteriodMC();
			var asteroid5:MovieClip = new AsteriodMC();


			var delayTimer = new Timer(5);
			var cx = stage.stageWidth/2;
			var cy = stage.stageHeight/2;
			//var i = 0;
			//var j = 2;
            
			var bckg:MovieClip=new BackgroundMC();
			bckg.x=stage.stageWidth/2;
			bckg.y=stage.stageHeight/2;
				
			
			// Function to rotate the asteroids by getting the circumference
				
		delayTimer.addEventListener(TimerEvent.TIMER, rotateCircle); 
		delayTimer.start();	


		 function rotateCircle(event:TimerEvent):void 
			{
	
	
			i = (i + 1) % 360;
			var cord = GetCircumferencePoints(50,cx,cy,(i*Math.PI/180));
			
			
	
			/*
			asteroid1.x = cord[0];
			asteroid1.y = cord[1];
			asteroid2.x = cord[0];
			asteroid2.y = cord[2];
			*/
			}

// defining the radius for each asteroids
function GetCircumferencePoints(Radius, OriginX, OriginY, Angle)
{
	asteroid1.x = OriginX + Math.sin(Angle) * Radius ;
	asteroid1.y = OriginY - Math.cos(Angle) * Radius ;
	
	asteroid2.x = OriginX + Math.sin(Angle) * (Radius+10) ;
	asteroid2.y = OriginY - Math.cos(Angle) * (Radius+10) ;
	
	asteroid3.x = OriginX + Math.sin(Angle) * (Radius+40) ;
	asteroid3.y = OriginY - Math.cos(Angle) * (Radius+40) ;
	
	asteroid4.x = OriginX + Math.sin(Angle) * (Radius+75) ;
	asteroid4.y = OriginY - Math.cos(Angle) * (Radius+75) ;
	
	asteroid5.x = OriginX + Math.sin(Angle) * (Radius+100) ;
	asteroid5.y = OriginY - Math.cos(Angle) * (Radius+100) ;
	
	addChild(bckg);
	addChild(asteroid1);
	addChild(asteroid2);
	addChild(asteroid3);
	addChild(asteroid4);
	addChild(asteroid5);
	addChild(button);	
	
	/*
	var cord:Array = new Array();
	cord[0] = OriginX + Math.sin(Angle) * Radius ;
	cord[1] = OriginY - Math.cos(Angle) * Radius ; 
	cord[0] = OriginX + Math.sin(Angle) * Radius ;
	cord[1] = OriginY - Math.cos(Angle) * Radius ; 
	return cord;
	*/
}

		}
}
}